# **************************************
# --*-- coding: utf-8 --*--
# @Time    : 2024-11-04
# @Author  : white
# @FileName: base.py
# @Software: PyCharm
# **************************************
import ctypes
from tkinter import colorchooser


class Base:
    def __init__(self):
        pass

    def ui_init(self):
        raise NotImplementedError()

    def reg(self):
        raise NotImplementedError()

    def is_admin(self) -> bool:
        try:
            return ctypes.windll.shell32.IsUserAnAdmin()
        except:
            return False

    def choose_color(self):
        # 打开颜色选择器并返回所选颜色的 RGB 和十六进制值
        color = colorchooser.askcolor(title="选择颜色")
        return color

    @staticmethod
    def clear_frame(func):
        """
        清空frame
        """

        def wrapper(*args, **kwargs):
            self = args[0]
            for widget in self.right_frame.winfo_children():
                widget.destroy()
            return func(*args, **kwargs)

        return wrapper
